package com.dzjcloud.dzj.upms.biz.utils;


import cn.hutool.core.lang.Validator;

import com.dzjcloud.dzj.common.minio.MinioProperties;
import com.dzjcloud.dzj.common.minio.utils.BucketUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * <h3>jiayou</h3>
 * <p>Minio路径工具</p>
 *
 * @author : DongZeJian
 * @date : 2020-09-02 10:22
 **/
@Component
public class MinioURLUtils {

    @Resource
    private MinioProperties minioProperties;

    /**
     * 获取UPMS文件绝对路径
     *
     * @param fileName 文件名称
     * @return 绝对路径
     */
    public String getMinioURl(String fileName, Integer uploadType) {
        return minioProperties.getUrl() + getMinioURLBucket(uploadType) + fileName;
    }

    public String getMinioURLBucket(Integer uploadType){
		String bucketName = Validator.validateNotEmpty(BucketUtils.getValue(uploadType), "输入的参数不正确");
    	return "/"+bucketName+"/";
	}
}
